# while True:
# 	n = int(input().strip())
#     assert n > 0
#     assert n>0
#     mlist=[]
#     if i in range(1,n+1):
#         mlist.append[i]
#     string=''.join(mlist)
#     res=0
#     for s in string:
#         if s =='1':
#             res+=1
#     print(res)
while True:
    n = int(input().strip())
    assert n>0
    mlist=[]
    for i in range(1,n+1):
        mlist.append(str(i))
    string = ''.join(mlist)

    res=0
    for s in string:
        if s == '1':
            res += 1
    print(res)
